package com.lfx.concurrent;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;

public class CompletTableFutureMain1 {

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        CompletableFuture<String> stringCompletableFuture = new CompletableFuture<>();
        CompletableFuture.runAsync(()-> {
            try {
                Thread.sleep(4000);
                System.out.println("执行任务了");
                stringCompletableFuture.complete("3333");
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        });

        String result = stringCompletableFuture.get();
        System.out.println("result"+result);

    }
}
